<?php

namespace App\Http\Controllers;

use App\Http\Requests\StoreExpertRequest;
use App\Http\Controllers\ExpertController;
use App\Http\Controllers\Controller;
use App\Models\Expert;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use PhpParser\Node\Expr\New_;

class AdminController extends Controller
{
    //
    public function ai(){//后台初始界面
        return view('admin.admin-index');
    }
    public function usl(){//后页用户管理界面
        return view('admin.user-show-list');
    }
    public function eal(){//后台专家管理界面
//        $expert = Expert::paginate(8);
//
//        return view('admin.expert-show-list')->with('expert',$expert);
    }
    public function expertadd(){

        return view('admin.expert-add-list');
    }

    public function login(){//后台登录界面
        return view('admin.login');

    }
    public function dologin(Request $request){
        $username=$request->username;
        $password=$request->password;
        if(Auth::attempt(['username'=>$username,'password'=>$password])){
            return json_encode(['success'=>true,'msg'=>"登录成功"]);
        }else{
            return json_encode(['success'=>false,'msg'=>'登录失败！用户名或密码错误']);
        }
    }
    public function logout(){//用户注销
        Auth::logout();
        return redirect("/adm/login");
    }
    public function v(){
        return view('admin.videos');
    }
    public function Estore(StoreExpertRequest $request)
    {
//        $request->validated();//验证错误信息
//        $expert= New ExpertController();
//       $expert->store($request);
//       return redirect('/expert-show-list');
    }
    public function expertedit($id){
//        $expert= Expert::find($id);
//        redirect('/expert-show-list');
//        return view('admin.expert-edit-list')->with('expert',$expert);
    }
    public function Eupdate(StoreExpertRequest $request,$id){
//        $request->validated();//验证错误信息
//        $expert= New ExpertController();
//        $expert->update($request,$id);
//        return redirect('/expert-show-list');
    }

}
